package com.traffic.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.traffic.domain.UserEduinformation;
import com.traffic.service.IUserEduinformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户学历信息Controller
 * 
 * @author zzs
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/eduinformation")
public class UserEduinformationController extends BaseController
{
    @Autowired
    private IUserEduinformationService userEduinformationService;

    /**
     * 查询用户学历信息列表
     */
    @RequiresPermissions("information:eduinformation:list")
    @GetMapping("/list")
    public TableDataInfo list(UserEduinformation userEduinformation)
    {
        startPage();
        List<UserEduinformation> list = userEduinformationService.selectUserEduinformationList(userEduinformation);
        return getDataTable(list);
    }

    /**
     * 导出用户学历信息列表
     */
    @RequiresPermissions("information:eduinformation:export")
    @Log(title = "用户学历信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserEduinformation userEduinformation)
    {
        List<UserEduinformation> list = userEduinformationService.selectUserEduinformationList(userEduinformation);
        ExcelUtil<UserEduinformation> util = new ExcelUtil<UserEduinformation>(UserEduinformation.class);
        util.exportExcel(response, list, "用户学历信息数据");
    }

    /**
     * 获取用户学历信息详细信息
     */
    @RequiresPermissions("information:eduinformation:query")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(userEduinformationService.selectUserEduinformationByUserId(userId));
    }

    /**
     * 新增用户学历信息
     */
    @RequiresPermissions("information:eduinformation:add")
    @Log(title = "用户学历信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserEduinformation userEduinformation)
    {
        return toAjax(userEduinformationService.insertUserEduinformation(userEduinformation));
    }

    /**
     * 修改用户学历信息
     */
    @RequiresPermissions("information:eduinformation:edit")
    @Log(title = "用户学历信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserEduinformation userEduinformation)
    {
        return toAjax(userEduinformationService.updateUserEduinformation(userEduinformation));
    }

    /**
     * 删除用户学历信息
     */
    @RequiresPermissions("information:eduinformation:remove")
    @Log(title = "用户学历信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(userEduinformationService.deleteUserEduinformationByIds(ids));
    }
}
